package net.seninp.fdata.data;

import java.util.HashMap;
import java.util.Iterator;

public class Years implements Iterable<Year> {

  private HashMap<Integer, Year> years;

  public Years() {
    this.years = new HashMap<Integer, Year>();
  }

  public void add(Measurement m) {
    if (!years.containsKey(m.getYear())) {
      years.put(m.getYear(), new Year(m.getYear()));
    }
    years.get(m.getYear()).add(m);
  }

  @Override
  public Iterator<Year> iterator() {
    return this.years.values().iterator();
  }

  public Year get(Integer y) {
    return this.years.get(y);
  }

}
